
import { addAiEvent, } from "@/api/modules/saiyiUser";
export const getCurrentPageUrl = () => {
  var pages = getCurrentPages()    //获取加载的页面
  var currentPage = pages[pages.length - 1]    //获取当前页面的对象
  var url = currentPage.route    //当前页面url
  return url
}
export const dateFormat = (val, type) => {
  let time = ''
  if (val !== null) {
    let val1 = val.replace(/-/g, '/');
    const date = new Date(val1)
    console.log('data', date);
    const year = date.getFullYear()
    var month = date.getMonth() + 1
    month = month > 9 ? month : '0' + month
    var day = date.getDate()
    day = day > 9 ? day : '0' + day
    var hh = date.getHours()
    hh = hh > 9 ? hh : '0' + hh
    var mm = date.getMinutes()
    mm = mm > 9 ? mm : '0' + mm
    var ss = date.getSeconds()
    ss = ss > 9 ? ss : '0' + ss
    var ms = date.getMilliseconds()
    if (type === 'fullTime') {
      time = year + '年' + month + '月' + day + '日 ' + hh + '点' + mm + '分'
    } else if (type === 'time') {
      time = hh + '点' + mm + '分' + ss + '秒'
    } else if (type === 'day') {
      time = year + '-' + month + '-' + day + ''
    } else if (type === 'langFullTime') {
      time = year + '年' + month + '月' + day + '日 ' + hh + '点' + mm + '分' + ss + '秒' + ms + '毫秒'
    }
  }
  return time
}

export const shareEvent = (options, type='SHARE_CARD') => {
  // return new Promise((resolve, reject) => {
  const { title, path } = options
  const eventType = type || 'SHARE_CARD'
  getAddAiEvent({ eventType })
  return {
    title: title,    // 默认是小程序的名称
    path: '/' + path,    // 默认是当前页面，必须是以‘/'开头的完整路径
    // imageUrl: imageUrl,   //自定义图片路径，可以是本地文件路径、代码包文件路径或者网络图片路径，支持PNG及JPG，不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
  };

  // })

}
export const getAddAiEvent = (parms) => {
  addAiEvent(parms).then(res => {
    console.log(res);
  })
}